﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class DebitMap : EntityConfigurationBase<Debit>
    {
        public DebitMap()
        {
            this.Property(p => p.Money).HasPrecision(18, 2);
            this.Property(p => p.Remark).HasMaxLength(200);
            this.Property(p => p.DebitorName).HasMaxLength(20);

            this.HasRequired(p => p.Debitor).WithMany().HasForeignKey(f=>f.DebitorId);
            this.HasRequired(p => p.Type).WithMany().HasForeignKey(f=>f.TypeId);
            this.HasOptional(p => p.Payment).WithMany().HasForeignKey(f=>f.PaymentId);
            this.HasOptional(p => p.Insurance).WithMany().HasForeignKey(f=>f.InsuranceId);
            this.HasRequired(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
        }
    }
}
